home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Linux Cubed Series 7: Sunsite
/
Linux Cubed Series 7 - Sunsite Vol 1.iso
/
system
/
emulator
/
bsvc-1.000
/
bsvc-1
/
bsvc-1.0.4
/
src
/
Assemblers
/
hecasm
/
asm6.c
< prev
next >
Wrap
C/C++ Source or Header
|
1995-07-26
|
5KB
|
158 lines
/* this contains all the global variable declarations and the */
/* contents of the permanent symbol table */
#include "asm.h"
/* flags */
int lflag=0; /* -l flag */
int nflag=0; /* -n flag */
/* program directive variables */
int radix = DEC; /* default radix */
/* position */
int pass=0; /* Which pass? */
int lineno=0; /* Line number */
/* text buffers */
char *sptr=0; /* Source pointer */
char sbuf[SRCMAX]; /* Source buffer */
int *cptr=0; /* Listing code pointer */
int cbuf[CLMAX]; /* Listing code buffer */
char *eptr=0; /* Error pointer */
char ebuf[ERRMAX]; /* Error buffer */
int cadr; /* address of object line */
int crec; /* next object word */
int crbf[CBMAX]; /* object code buffer */
int refcnt=0; /* Reference counter */
/* listing flags */
int listmode; /* listing mode for a line */
int listaddr; /* start address of a line */
/* line assembly */
int opcode; /* instruction opcode */
/* file pointers */
FILE *ifp = NULL; /* input file pointer */
FILE *ofp = NULL; /* output file pointer */
FILE *lfp = NULL; /* listing file pointer */
/*
* Reference table
*/
struct reflst reftab[REFMAX] =
{
0,NULL
};
/*
* User symbol table.
*/
struct sym ust[USERMAX];
/* pointer to the location counter in the ust */
struct sym *dot;
/*
* Opcode table.
* Also contains pseudo operations and
* registers.
*/
/* this table is search by a binary search therefore alphabetical */
/* order must be maintained. See asm.h for details of table contents */
struct sym pst[] = {
".byte", GR_BYTE, 0, NULL, 0, 1,
".cc", GR_CC, 0, NULL, 7, 1,
".cs", GR_CC, 0, NULL, 15, 1,
".eq", GR_CC, 0, NULL, 13, 1,
".equ", GR_EQU, 0, NULL, 0, 1,
".f", GR_CC, 0, NULL, 3, 1,
".ge", GR_CC, 0, NULL, 2, 1,
".gt", GR_CC, 0, NULL, 12, 1,
".hi", GR_CC, 0, NULL, 14, 1,
".le", GR_CC, 0, NULL, 4, 1,
".list", GR_LIST, 0, NULL, 0, 1,
".ls", GR_CC, 0, NULL, 6, 1,
".lt", GR_CC, 0, NULL, 10, 1,
".mi", GR_CC, 0, NULL, 9, 1,
".ne", GR_CC, 0, NULL, 5, 1,
".org", GR_ORG, 0, NULL, 0, 1,
".pascii", GR_PASCII, 0, NULL, 0, 1,
".pl", GR_CC, 0, NULL, 1, 1,
".radix", GR_RADIX, 0, NULL, 0, 1,
".rmb", GR_RMB, 0, NULL, 0, 1,
".rmw", GR_RMW, 0, NULL, 0, 1,
".t", GR_CC, 0, NULL, 11, 1,
".uascii", GR_UASCII, 0, NULL, 0, 1,
".vc", GR_CC, 0, NULL, 0, 1,
".vs", GR_CC, 0, NULL, 8, 1,
".word", GR_WORD, 0, NULL, 0, 1,
"add", GR_FMT1, 0, NULL, 0x0000, 1,
"addc", GR_FMT1, 0, NULL, 0x1000, 1,
"and", GR_FMT1, 0, NULL, 0x3000, 1,
"bra", GR_FMT3, 0, NULL, 0xc000, 1,
"btst", GR_FMT1, 0, NULL, 0xb000, 1,
"clc", GR_FMT4, 0, NULL, 0xf100, 1,
"cli", GR_FMT4, 0, NULL, 0xf300, 1,
"clr", GR_FMT2, 0, NULL, 0xc300, 1,
"cmp", GR_FMT1, 0, NULL, 0xa000, 1,
"dec", GR_FMT2, 0, NULL, 0x8300, 1,
"exch", GR_FMT6, 0, NULL, 0xf600, 1,
"inc", GR_FMT2, 0, NULL, 0x8200, 1,
"jsr", GR_FMT3, 0, NULL, 0xc100, 1,
"ldf", GR_FMT2, 0, NULL, 0xe200, 1,
"move", GR_FMT8, 0, NULL, 0xd000, 1,
"neg", GR_FMT2, 0, NULL, 0x8100, 1,
"not", GR_FMT2, 0, NULL, 0x8000, 1,
"or", GR_FMT1, 0, NULL, 0x5000, 1,
"pc", GR_REG, 0, NULL, 15, 1,
"push", GR_FMT5, 0, NULL, 0xe300, 1,
"r0", GR_REG, 0, NULL, 0, 1,
"r1", GR_REG, 0, NULL, 1, 1,
"r10", GR_REG, 0, NULL, 10, 1,
"r11", GR_REG, 0, NULL, 11, 1,
"r12", GR_REG, 0, NULL, 12, 1,
"r13", GR_REG, 0, NULL, 13, 1,
"r14", GR_REG, 0, NULL, 14, 1,
"r15", GR_REG, 0, NULL, 15, 1,
"r2", GR_REG, 0, NULL, 2, 1,
"r3", GR_REG, 0, NULL, 3, 1,
"r4", GR_REG, 0, NULL, 4, 1,
"r5", GR_REG, 0, NULL, 5, 1,
"r6", GR_REG, 0, NULL, 6, 1,
"r7", GR_REG, 0, NULL, 7, 1,
"r8", GR_REG, 0, NULL, 8, 1,
"r9", GR_REG, 0, NULL, 9, 1,
"rol", GR_FMT2, 0, NULL, 0x9100, 1,
"ror", GR_FMT2, 0, NULL, 0x9300, 1,
"rti", GR_FMT4, 0, NULL, 0xf400, 1,
"rts", GR_FMT4, 0, NULL, 0xd8ef, 1,
"sec", GR_FMT4, 0, NULL, 0xf000, 1,
"sei", GR_FMT4, 0, NULL, 0xf200, 1,
"shl", GR_FMT2, 0, NULL, 0x9000, 1,
"shr", GR_FMT2, 0, NULL, 0x9200, 1,
"sp", GR_REG, 0, NULL, 14, 1,
"srch", GR_FMT7, 0, NULL, 0xf700, 1,
"stf", GR_FMT2, 0, NULL, 0xe100, 1,
"stop", GR_FMT4, 0, NULL, 0x7000, 1,
"sub", GR_FMT1, 0, NULL, 0x2000, 1,
"subc", GR_FMT1, 0, NULL, 0x4000, 1,
"swap", GR_FMT2, 0, NULL, 0xc200, 1,
"swi", GR_FMT4, 0, NULL, 0xf500, 1,
"test", GR_FMT2, 0, NULL, 0xe000, 1,
"xor", GR_FMT1, 0, NULL, 0x6000, 1,
};
/* calculate the size of the permantent symbol table */
int pstsize = sizeof(pst)/sizeof(pst[0]);
/* this is a pointer to the end of the reference table */
struct reflst *refptr = &reftab[0]; /* Pointer to end of reference table */